home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / graphics / vlapak1.zip / VLA_FONT.ZIP / HSCR2X.ASM < prev    next >
Assembly Source File  |  1993-09-28  |  6KB  |  274 lines

  1.     IDEAL
  2.     DOSSEG
  3.     MODEL SMALL
  4.     STACK 200h
  5.     CODESEG
  6.     p386
  7.     
  8.     ASSUME CS:@CODE, DS:@CODE
  9. ────────────────────────────────────────────────────────────────────────────
  10. STRUC VCHHDR
  11.     Ident   db  "VLACH"
  12.     From    db  ?
  13.     X       db  ?
  14.     Y       db  ?
  15.     NumChar db  ?
  16. ENDS
  17.  
  18. STRUC Pal
  19.     R       db  ?
  20.     G       db  ?
  21.     B       db  ?
  22. ENDS
  23. ────────────────────────────────────────────────────────────────────────────
  24. INCLUDE "MODEX.INC"
  25.  
  26. FileName_VCH    db      "Font5.VCH",0
  27. FileName_PAL    db      "Font5.PAL",0
  28.  
  29. Seg_VCH         dw      0
  30.  
  31. Palette         Pal     256 dup (<>)
  32. VCHHEADER       VCHHDR  <>
  33. CharWidths      db      256 dup (0)
  34.  
  35. TheMessage      db      " WOW!  THE FONT FOR THIS SCROLLER IS 2X THE SIZE "
  36.                 db      "OF THE 1X VERSION... PROBABLY WHY I LABELED IT 2X.."
  37.                 db      ".  I HATE SCROLLERS BECAUSE I HAVE NOTHING TO SAY.."
  38.                 db      "         "
  39.                 db      0
  40.  
  41. MsgOff          dw      offset TheMessage
  42. CharOff         dw      0       ;offset to current column to draw of chr
  43. XYsize          dw      ?       ;number of bytes in a char
  44. CurColumn       db      1
  45. DestOff         dw      0
  46. SCReenWidth     =       130
  47. ────────────────────────────────────────────────────────────────────────────
  48.     ────────────────────────────────────────────────────────────────────
  49.     ; Load in the font named in FileName_VCH and loads in the Palette
  50.     ; named in FileName_PAL. 
  51.     ;
  52.     ; Returns CF = 1 if there was an error
  53.     ────────────────────────────────────────────────────────────────────
  54. PROC LoadFont NEAR
  55.     pusha
  56.     push    ds
  57.  
  58.     mov     ax,cs
  59.     mov     ds,ax
  60.     mov     dx,offset FileName_PAL      ;open the palette file
  61.     mov     ax,3d00h
  62.     int     21h
  63.     jc      @@Error
  64.     mov     bx,ax
  65.  
  66.     mov     dx,offset Palette           ;read in the palette
  67.     mov     cx,768
  68.     mov     ah,3fh
  69.     int     21h
  70.  
  71.     mov     ah,3eh                      ;close PAL file
  72.     int     21h
  73.  
  74.     mov     dx,offset FileName_VCH      ;open VCH file
  75.     mov     ax,3d00h
  76.     int     21h
  77.     jc      @@Error
  78.     mov     bx,ax
  79.  
  80.     mov     dx,offset VCHHeader         ;load in the header
  81.     mov     cx,size VCHHDR
  82.     mov     ah,3fh
  83.     int     21h
  84.  
  85.     mov     al,[VCHHEADER.X]            ;calc data size
  86.     mul     [VCHHEADER.Y]
  87.     mov     [XYsize],ax
  88.     movzx   cx,[VCHHEADER.NumChar]
  89.     mul     cx
  90.     mov     cx,ax
  91.  
  92.     mov     ax,[cs:SEG_VCH]             ;move SEG_VCH into DS, but be sure
  93.     or      ax,ax                       ;the segment isn't 0
  94.     stc
  95.     je      @@Error
  96.     mov     ds,ax
  97.     xor     dx,dx                       ;load in the data
  98.     mov     ah,3fh
  99.     int     21h
  100.  
  101.     mov     ax,cs
  102.     mov     ds,ax
  103.     mov     dx,offset CharWidths
  104.     movzx   cx,[VCHheader.NumChar]
  105.     mov     ah,3fh
  106.     int     21h                         ;read in widths of chars
  107.  
  108.     mov     ah,3eh                      ;close VCH file
  109.     int     21h
  110.     clc
  111.  
  112. @@Error:
  113.  
  114.     pop     ds
  115.     popa
  116.     ret
  117. ENDP
  118.     ────────────────────────────────────────────────────────────────────
  119.     ;Starts the next letter in the message
  120.     ────────────────────────────────────────────────────────────────────
  121. PROC NewChar NEAR
  122.     pusha
  123.     push    ds
  124.     mov     ax,cs
  125.     mov     ds,ax
  126.  
  127.     mov     si,[MsgOff]     ;get the offset to the next char
  128. @@MsgLoop:
  129.     lodsb
  130.     or      al,al
  131.     jne     @@IsaChar
  132.     mov     si,offset TheMessage
  133.     jmp short @@MsgLoop
  134.  
  135. @@IsaChar:
  136.     mov     ah,[VCHHEADer.From]
  137.     add     ah,[VCHHEADer.NumChar]
  138.     cmp     al,[VCHHEADer.FROM]
  139.     jb      @@MsgLoop
  140.     cmp     al,ah
  141.     ja      @@MsgLoop
  142.  
  143.     mov     [MsgOff],si
  144.     sub     al,[VCHheader.From]
  145.     movzx   ax,al
  146.     mov     bx,ax
  147.     mul     [XYsize]
  148.     mov     [CharOff],ax
  149.     
  150.     mov     al,[CharWidths + bx]
  151.     mov     [CurColumn],al
  152.     
  153.     pop     ds
  154.     popa
  155.     ret
  156. ENDP
  157.     ────────────────────────────────────────────────────────────────────
  158.     ; Draws the Next column onto the screen, calls NewChar if done with
  159.     ; current character
  160.     ────────────────────────────────────────────────────────────────────
  161. PROC DrawColumn NEAR
  162.     pusha
  163.     push    ds es fs
  164.     mov     ax,cs
  165.     mov     ds,ax
  166.  
  167.     mov     bx,[DestOff]
  168.     add     bx,2
  169.     @Set_Start_Offset
  170.  
  171.     sub     [CurColumn],2
  172.     jg      @@NoNew
  173.  
  174.     call    NewChar
  175.  
  176. @@NoNew:
  177.     mov     fs,[SEG_VCH]
  178.     mov     es,[VGASEG]
  179.  
  180.     mov     bp,SCReenWidth         ;screen width
  181.  
  182.     mov     dx,SC_Index
  183.     mov     ax,0302h
  184.     out     dx,ax
  185.  
  186.     movzx   dx,[VCHheader.X]
  187.     movzx   cx,[VCHheader.Y]
  188.     mov     si,[CharOff]    ;fs:si points to the data
  189.     mov     di,[DestOff]
  190. @@Zloop:
  191.     mov     al,[fs:si]
  192.     mov     [es:di],al
  193.     mov     [es:di+SCReenWidth/2],al
  194.     add     di,bp
  195.  
  196.     add     si,dx
  197.  
  198.     loop    @@ZLoop
  199.     
  200.     mov     dx,SC_Index
  201.     mov     ax,0C02h
  202.     out     dx,ax
  203.  
  204.     movzx   dx,[VCHheader.X]
  205.     movzx   cx,[VCHheader.Y]
  206.     mov     si,[CharOff]    ;fs:si points to the data
  207.     inc     si
  208.     mov     di,[DestOff]
  209. @@Zloop2:
  210.     mov     al,[fs:si]
  211.     mov     [es:di],al
  212.     mov     [es:di+SCReenWidth/2],al
  213.     add     di,bp
  214.  
  215.     add     si,dx
  216.  
  217.     loop    @@ZLoop2
  218.     
  219.  
  220.     inc     [DestOff]
  221.     cmp     [DestOff],ScreenWidth/2
  222.     jb      @@okok
  223.  
  224.     mov     [DestOff],0
  225.  
  226. @@okok:
  227.     add     [CharOff],2
  228.  
  229.     pop     fs es ds
  230.     popa
  231.     ret
  232. ENDP
  233. ────────────────────────────────────────────────────────────────────────────
  234. START:
  235.     mov     ax,cs
  236.     mov     ds,ax
  237.  
  238.     mov     ax,ss
  239.     mov     bx,sp
  240.     add     bx,15
  241.     shr     bx,4
  242.     add     ax,bx
  243.     mov     [SEG_VCH],ax
  244.  
  245.     @SetModeX m256x200x256, 520
  246.  
  247.     call    LoadFont
  248.     mov     si,offset Palette
  249.     mov     cx,256
  250.     mov     al,0
  251.     @WritePalette
  252.     
  253.     mov     dx,CRTC_Index
  254.     mov     al,9
  255.     mov     ah,3    ;each dot is 4 high (use HEIGHT-1)
  256.     out     dx,ax
  257.  
  258. @@MainLoop:
  259.     @FullVertWait
  260.     call    DrawColumn
  261.  
  262.     mov     ah,1
  263.     int     16h
  264.     jz      @@MainLoop
  265.  
  266.     mov     ah,0
  267.     int     16h
  268.  
  269.     mov     ax,3
  270.     int     10h
  271.     mov     ax,4c00h
  272.     int     21h
  273. END START
  274.